package com.itheima.jdbc.lianxi;

import java.sql.*;

public class Test2 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //1 注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //2,获取链接
        String url="jdbc:mysql://192.168.36.74/db1?useSSL=false";
        String uesr="root";
        String password="1234";
        Connection connection = DriverManager.getConnection(url, uesr, password);
        String sql="select * from emp ";
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery(sql);
        while (resultSet.next()){
            int id = resultSet.getInt(1);
            String ename = resultSet.getString(2);
            int job_id = resultSet.getInt(3);   
            int mgr = resultSet.getInt(4);
            Date joindate = resultSet.getDate(5);
            double salary = resultSet.getDouble(6);
            double bonus = resultSet.getDouble(7);
            int deptid = resultSet.getInt(8);
            System.out.println("id为: "+id+"名字: "+ename+"工作ID: "+job_id+mgr+"加入日期: "+joindate+"工资: "+salary+"奖金: "+bonus+" "+deptid);
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}
